package lanqiao;
/**
 * @Project : ProgrammingExercises
 * @Package : LanQiao.PrepareForCompetition
 * @File : Q0130.java
 * @Author : WangRuoyu
 * @Date : 2023/3/16 9:16
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q0130 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");

        int k = Integer.parseInt(words[0]);
        int m = Integer.parseInt(words[1]);
        int n = Integer.parseInt(words[2]);
        int m1;
        int m2;
        int n1;
        int n2;

        if (m % k == 0) {
            m1 = m / k;
        } else {
            m1 = m / k + 1;
        }

        if (m1 % 2 != 0) {
            m2 = m - (m1 - 1) * k;
        } else {
            m2 = m1 * k - m + 1;
        }

        if (n % k == 0) {
            n1 = n / k;
        } else {
            n1 = n / k + 1;
        }

        if (n1 % 2 != 0) {
            n2 = n - (n1 - 1) * k;
        } else {
            n2 = n1 * k - n + 1;
        }

        System.out.println(Math.max(m2, n2) - Math.min(m2, n2) + Math.max(m1, n1) - Math.min(m1, n1));

    }
}
